Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shot

Package Overview
Dependencies
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shot

Injects a fake HTTP request/response into a node HTTP server

  • 3.5.2
  • v3-legacy
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-67.04%
Maintainers
4
Weekly downloads
 
Created
Source

shot

Injects a fake HTTP request/response into a node HTTP server for simulating server logic, writing tests, or debugging. Does not use a socket connection so can be run against an inactive server (server not in listen mode).

Build Status

Example

// Load modules

const Http = require("http");
const Shot = require("shot");

// Declare internals

const internals = {};

internals.main = function () {
  const dispatch = function (req, res) {
    const reply = "Hello World";
    res.writeHead(200, {
      "Content-Type": "text/plain",
      "Content-Length": reply.length,
    });
    res.end(reply);
  };

  const server = Http.createServer(dispatch);

  Shot.inject(dispatch, { method: "get", url: "/" }, (res) => {
    console.log(res.payload);
  });
};

internals.main();

Note how server.listen is never called.

API

See the API Reference

Keywords

FAQs

Package last updated on 06 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc